package com.tiansu.reborn.wanda.modules.executor.service.impl;

import com.tiansu.reborn.wanda.modules.executor.dao.ExamineDao;
import com.tiansu.reborn.wanda.modules.executor.entity.ExamineEntity;
import com.tiansu.reborn.wanda.modules.executor.entity.result.ExamineResult;
import com.tiansu.reborn.wanda.modules.executor.entity.vo.ExamineChangeVo;
import com.tiansu.reborn.wanda.modules.executor.entity.vo.ExamineSelectVo;
import com.tiansu.reborn.wanda.modules.executor.service.ExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ExamineServiceImpl implements ExamineService {

    @Autowired
    private ExamineDao examineDao;

    @Override
    public ExamineResult getShowData(ExamineSelectVo vo) {
        ExamineResult result = new ExamineResult();
        List<ExamineEntity> dbResult =  examineDao.getShowData(vo);
        result.setList(dbResult);
        return result;
    }

    @Override
    public String updateData(ExamineChangeVo vo) {
        String result = null;
        int rows = examineDao.updateData(vo);
        if(rows>0) {
            result = "成功!";
        }
        if(rows==0){
            result = "修复状态与原状态相同,无需修复！";
        }
        if(rows<0){
            result = "数据库错误,修复失败!";
        }
        return result;
    }
}
